#ifndef __BOX_H
#define __BOX_H

#include <SDL/SDL.h>
#include "vector2.h"
#include "defaultsetting.h"

class Box
{
	public:
    /**
      * @returns A non initialized box
      */
		Box();
    
    /**
      * @returns A new box by giving implicit coordinates. If coordinates
      * involve a negative size, it will be changed to zero
      */
		Box(const REAL x,const REAL y,const REAL w,const REAL h);
    
    /**
      * @returns A new box by giving coordinates into two Vector2 objects.
      * If coordinates involve a negative size, it will be changed to
      * zero
      */
		Box(const Vector2 mi,const Vector2 si);
    
    /**
      * @returns A new box by giving another box
      */
		Box(const Box &b);
    
    /**
      * @returns A new box by giving a SDL box
      */
		Box(const SDL_Rect r);
    
    /**
      * @returns A new box by giving a pointer SDL box
      */
		Box(const SDL_Rect *r);
    
    /**
      * It does not do anything special
      */
		virtual ~Box();
    
    /**
      * Modify the actual position of the box by moving it
      */
		void move(const Vector2 &v);
    
    /**
      * Modify the actual position of the box by warping it
      */
		void locate(const Vector2 &v);
    
    /**
      * Modify the actual position of the box by warping it
      */
		void locate(const int x,const int y);
    
    /**
      * Modify the position of the nearest vertex.
      */
		void setMin(const Vector2 &v);
    
    /**
      * Modify the position of the nearest vertex.
      */
		void setMin(const int x,const int y);
    
    /**
      * Modify the size of the box. If it involves a negative size
      * the box will not be modified
      */
		void setSize(const Vector2 &v);
    
    /**
      * Modify the size of the box. If it involves a negative size
      * the box will not be modified
      */
		void setSize(const int x,const int y);
    
    /**
      * Modify coordinate x from Vector2 m_min.
      */
		void setX(const REAL ax);
    
    /**
      * Modify coordinate y from Vector2 m_min
      */
		void setY(const REAL ay);
    
    /**
      * Modify coordinate w from Vector2 m_size
      * If it involves a negative size the box will not be modified
      */
		void setW(const REAL aw);
    
     /**
      * Modify coordinate w from Vector2 m_size
      * If it involves a negative size the box will not be modified
      */
		void setH(const REAL ah);
    
    /**
      * @returns Coordinate x of Vector2 m_min
      */
    REAL getX();
    
    /**
      * @returns Coordinate y of Vector2 m_size
      */
    REAL getY();
    
    /**
      * @returns Coordinate x of Vector2 m_min
      */
    REAL getW();
    
    /**
      * @returns Coordinate y of Vector2 m_size
      */
    REAL getH();
    
    /**
      * @returns A SDL box 
      */
		SDL_Rect getSDLRect();
    
    /**
      * @returns the nearest vertex
      */
		Vector2 getMin()const;
    
    /**
      * @returns the size of the box
      */
		Vector2 getSize()const;
    
    /**
      * @returns the farest vertex
      */
		Vector2 getMax()const;

	protected:
		Vector2 m_min;
		Vector2 m_size;
    
};

#endif
